import { GuideCfg } from "../../config/GuideCfg";
import { PrefabPath } from "../../config/PrefabPath";
import DialogBase from "../../core/common/DialogBase";
import UIManager from "../../core/managers/UIManager";
import { UserStore } from "../../core/store/UserStore";
import { observer, render } from "../../mobx/observer";


const { ccclass, property } = cc._decorator;
/**
 * 登陆奖励
 */
@ccclass
@observer
export default class DialogSetting extends DialogBase {


    @property({ type: cc.Button, displayName: '关闭' })
    btnClose: cc.Button = null;

    @property({ type: cc.Slider, displayName: '音乐' })
    silderMusic: cc.Slider = null;

    @property({ type: cc.Slider, displayName: '音效' })
    silderEffect: cc.Slider = null;
    start() {

    }
    onClose() {
        UIManager.hide(PrefabPath.setting);
    }

    onMusicSlider(e: cc.Slider) {
        UserStore.Ins.setMusic(+e.progress.toFixed(2))
    }

    onEffectSlider(e: cc.Slider) {
        UserStore.Ins.setEffect(+e.progress.toFixed(2))
    }
    private i = 0;
    async onMute(e: cc.Slider) {
        UserStore.Ins.mute()
        UIManager.showToast(`静音🔇`)
        this.i++;
    }

    @render
    renderSlider() {
        this.silderMusic.progress = UserStore.Ins.musicVoice;
        this.silderEffect.progress = UserStore.Ins.effectVoice;
    }
}
